import request from "../utils/request";
import {requestFilter} from "../utils/permiss";

export async function fetchPermission() {
    return await request.get('system/api/selectUserRoleMenu')
}

// 获取登录验证码
export async function getLoginCode(params) {
    return await request.get('user/validateCode', {params: params, responseType: "arraybuffer"})
}

// 登录
export async function onLogin(params) {
    return await request.post('system/api/sysLogin', params)
}

// 客服下拉
export async function selectSystemUser(params) {
    return await request.get('system/api/getSystemUser', {params})
}
// 首页客服下拉
export async function selectHomeSystemUser(params) {
    return await request.get('system/api/getSystemUserList', {params})
}
// 获取渠道下拉
export async function selectChannelList(params) {
    return await request.get('system/api/channelList', {params})
}

// 获取商户下拉列表
export async function selectMerchant(params) {
    if (requestFilter('merchant/merchantListDropDown')) {
        const res = await request.post('merchant/merchantListDropDown', params)
        return res.code === 200 ? res.data : []
    } else {
        return []
    }
}

// 修改密码
export async function updatePassword(params) {
    return await request.post('system/api/updatePassword', params)
}

// 修改密码
export async function loginOut(params) {
    return await request.get('system/api/sysOutLogin', {params})
}

// 首页资金统计
export async function fetchHomeMoney(params = {}) {
    return await request.post('home/fundStatistics', params)
}

// 今日数据统计
export async function fetchHomeTodayMoney(params = {}) {
    return await request.post('home/todayStatistics', params)
}

// 未指定商户列表
export async function fetchCollectionUnknown(params = {}) {
    return await request.post('collectionUnknown/list', params)
}


// 未指定商户导出
export async function collectionUnknownExport(params = {}) {
    return await request.post('collectionUnknown/export', params)
}

// 切换指定商户
export async function changeCollectionUnknown(params = {}) {
    return await request.post('collectionUnknown/appointMerchant', params)
}

// 费用配置查询
export async function getFeeConfig(params = {}) {
    return await request.get('system/api/getFee', {params})
}

// 费用配置编辑
export async function updateFeeConfig(params = {}) {
    return await request.post('system/api/updateFee', params)
}
// 费用配置查询
export async function getConsumeConfig(params = {}) {
    return await request.get('system/api/getConsumeConfig', {params})
}
// 费用配置编辑
export async function updateConsumeConfig(params = {}) {
    return await request.post('system/api/updateConsumeConfig', params)
}
// 获取用户反馈列表
export async function fetchProblemList(params) {
    return await request.get('system/api/userProblemList', {params})
}

/**
 *   首页接口
 */
// 客服下拉
export async function selectSystemUserList(params) {
    return await request.get('system/api/getSystemUserList', {params})
}

// 历史收入
export async function fetchIncomeHistory(params) {
    return await request.get('system/api/incomeHistory', {params})
}

// 今日收入
export async function fetchIncomeToday(params) {
    return await request.get('system/api/incomeToday', {params})
}

// 历史收款单数
export async function fetchInsertHistory(params) {
    return await request.get('system/api/insertHistory', {params})
}

// 今日收款单数
export async function fetchInsertToday(params) {
    return await request.get('system/api/insertToday', {params})
}

// 首页-总订单数
export async function fetchOrderNum(params) {
    return await request.get('system/api/orderNum', {params})
}
